#ifndef __DEVICECONTEXT_H__
#define __DEVICECONTEXT_H__
/////////////////
//include
/////////////////
#include<Windows.h>
#include<D3D11.h>
#include<D3DX11.h>
#include"Vector3D.h"
#include"InputElement.h"
#include"SphereModel.h"
#include"Sphere.h"
#include"SpriteDrawer.h"
#include"Texture2D.h"
#include"BoxModel.h"
/////////////////
//const
/////////////////

/////////////////
//class
/////////////////
class Model;
class Object;
class DeviceContext
{
public:
	DeviceContext(ID3D11DeviceContext* device_context = NULL,Device* device = NULL);
	~DeviceContext();
	void SetRenderTarget(int render_num,ID3D11RenderTargetView* render_target,ID3D11DepthStencilView* depth_stencil = NULL);
	void SetRasterizerState(ID3D11RasterizerState* state);
	void ClearRenderTarget(ID3D11RenderTargetView* render_target);
	void ClearDepth(ID3D11DepthStencilView* depth);
	void SetViewPort(float x,float y,float width ,float height,float min_depth = 0.0f,float max_depth = 1.0f);
	void SetViewPort(int view_ports_num,D3D11_VIEWPORT* view_ports);
	void SetVertexBuffer(ID3D11Buffer* vertex_buffer,UINT stride ,UINT offset, UINT start_slot = 0,UINT buffer_num = 1);
	void SetIndexBuffer(ID3D11Buffer* index_buffer ,DXGI_FORMAT format, UINT offset);
	void SetShader(ID3D11VertexShader* vs,ID3D11PixelShader* ps);
	void SetLayout(ID3D11InputLayout* layout);
	void SetTopology(D3D11_PRIMITIVE_TOPOLOGY topology);
	void SetShaderResource(ID3D11ShaderResourceView* resouce);
	void SetSamplerState(ID3D11SamplerState* sampler_state);
	void SetBlensState(ID3D11BlendState* blend_state);
	void SetDepthStencilState(ID3D11DepthStencilState* depth_state){device_context->OMSetDepthStencilState(depth_state,0);}
	D3D11_MAPPED_SUBRESOURCE Map(ID3D11Resource* resource);
	void UnMap(ID3D11Resource* resource);
	void SetConstantBuffer(ID3D11Buffer* constant_buffer,int slot_num);
	void UpdateBuffer(ID3D11Buffer* constant_buffer,void* date,int size);
	void SetPos(Vector3D pos);
	void SetRot(Vector3D rot);
	void SetScale(Vector3D size);
	void DrawPixel(D3D11_MAPPED_SUBRESOURCE mapped_sub_resource,Vector3D pos,float r,float g,float b,float a);
	void Draw(int vertex_num,int vertex_start_num);
	void DrawInstance(unsigned int vertex_num,unsigned int instance_num, unsigned int vertex_start_num);
	void DrawIndex(int index_num,int index_start_num);
	void DrawModel(Model* model);
	void DrawCollisionModel(Object* obje);

	void DrawSphere(const Sphere& sphere);
	void DrawBox(const Box& box);

	void DrawSprite(Texture2D* tex,float x,float y);

	ID3D11DeviceContext* GetDeviceContext() const{return device_context;}
private:
	ID3D11DeviceContext* device_context;
	ID3D11Buffer* matrix_buffer;
	static SphereModel	sphere;
	static BoxModel		box;
	SpriteDrawer* sprite_drawer;

};
#endif __DEVICECONTEXT_H__
